package com.zl.smartmall.library.po;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * 可提供的发票类型; 如: 明细、办公等
 * 
 * @author 陈希然
 * 
 */
public class InvoiceTypeInfo {

	private int type;
	private String name;

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public static List<InvoiceTypeInfo> parse(JSONArray jsonArray) throws JSONException {
		List<InvoiceTypeInfo> invoiceTypeInfos = new ArrayList<InvoiceTypeInfo>();
		for(int i = 0; jsonArray != null && i < jsonArray.length(); i++) {
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			if(jsonObject != null && jsonObject.length() > 0) {
				InvoiceTypeInfo invoiceTypeInfo = new InvoiceTypeInfo();
				invoiceTypeInfo.name = jsonObject.getString("name");
				invoiceTypeInfo.type = jsonObject.getInt("type");
				invoiceTypeInfos.add(invoiceTypeInfo);
			}
		}
		return invoiceTypeInfos;
	}
}
